#ifndef NMC_GRAPHICS_HPP
#define NMC_GRAPHICS_HPP

#include <string>

#include "color.hpp"
#include "rectangle.hpp"
#include "guichan/opengl/openglgraphics.hpp"

#if defined _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#if defined DELETE
#undef DELETE
#endif
#endif

#include <GL/gl.h>

namespace nmc
{
    class Graphics : public gcn::OpenGLGraphics
    {
    public:
		enum BlendMode
        {
            ADD,
            MULTIPLY,
            ALPHA
        };

        Graphics();
		
		~Graphics();

		void createRenderToTexture(int width, int height);

		void beginRenderToTexture();

		void endRenderToTexture();

		void drawRenderToTexture(int x, int y, int width, int height);


        /**
         * Sets the blend mode.
         *
         * @param mode The blend mode, see enum.
         */
        void setBlendMode(BlendMode mode);

        /**
         * Gets the blend mode.
         *
         * @return The blend mode, see enum.
         */
        BlendMode getBlendMode();

        /**
         * Rotates the drawing target around a point.
         *
         * @param x The x-coordinate.
         * @param y The y-coordinate.
         * @param angle The rotation angle in radians.
         */
        void rotate(int x, int y, float angle);

        /**
         * Scales the drawing target.
         *
         * @param x The x-coordinate.
         * @param y The y-coordinate.
         * @param xAmount The amount of scaling in the x-axis.
         * @param yAmount The amount of scaling in the y-axis.
         */
        void scale(int x, int y, float xAmount, float yAmount);

        /**
         * Translates the drawing target.
         *
         * @xAmount The amount to translate in the x-axis.
         * @yAmount The amount to translate in the y-axis.
         */
        void translate(int xAmount, int yAmount);

        /**
         * Pushes the OpenGL matrix.
         */
        void pushMatrix();

        /**
         * Pops the OpenGL matrix.
         */
        void popMatrix();


        // Inherited from OpenGLGraphics

        virtual void _beginDraw();

        virtual void setColor(const gcn::Color& color);
        
        static const float pi;

    private:
        BlendMode mBlendMode;
		int mRenderToTextureWidth;
		int mRenderToTextureHeight;
		GLuint mRenderToTextureHandle;
    };    
}

#endif